/*  1:   */ package org.jetbrains.jps.model.serialization;
/*  2:   */ 
/*  3:   */

import com.intellij.openapi.components.ExpandMacroToPathMap;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
import org.jdom.Element;
import org.jetbrains.annotations.Nullable;

import java.io.File;
import java.util.Map;

/*  4:   */
/*  5:   */
/*  6:   */
/*  7:   */
/*  8:   */
/*  9:   */
/* 10:   */
/* 11:   */ 
/* 12:   */ public class JpsMacroExpander
/* 13:   */ {
/* 14:   */   private ExpandMacroToPathMap a;
/* 15:   */   
/* 16:   */   public JpsMacroExpander(Map<String, String> paramMap)
/* 17:   */   {
/* 18:34 */     this.a = new ExpandMacroToPathMap();
/* 19:35 */     for (Map.Entry localEntry : paramMap.entrySet()) {
/* 20:36 */       addMacro((String)localEntry.getKey(), (String)localEntry.getValue());
/* 21:   */     }
/* 22:   */   }
/* 23:   */   
/* 24:   */   public void addFileHierarchyReplacements(String paramString, File paramFile)
/* 25:   */   {
/* 26:41 */     a("$" + paramString + "$", paramFile);
/* 27:   */   }
/* 28:   */   
/* 29:   */   protected void addMacro(String paramString1, String paramString2)
/* 30:   */   {
/* 31:45 */     this.a.addMacroExpand(paramString1, paramString2);
/* 32:   */   }
/* 33:   */   
/* 34:   */   private void a(String paramString, @Nullable File paramFile)
/* 35:   */   {
/* 36:49 */     if (paramFile == null) {
/* 37:49 */       return;
/* 38:   */     }
/* 39:50 */     a(paramString + "/..", paramFile.getParentFile());
/* 40:   */     
/* 41:52 */     String str = FileUtil.toSystemIndependentName(paramFile.getPath());
/* 42:53 */     if (StringUtil.endsWithChar(str, '/'))
/* 43:   */     {
/* 44:54 */       this.a.put(paramString + "/", str);
/* 45:55 */       this.a.put(paramString, str.substring(0, str.length() - 1));
/* 46:   */     }
/* 47:   */     else
/* 48:   */     {
/* 49:58 */       this.a.put(paramString, str);
/* 50:   */     }
/* 51:   */   }
/* 52:   */   
/* 53:   */   public void substitute(Element paramElement, boolean paramBoolean)
/* 54:   */   {
/* 55:63 */     this.a.substitute(paramElement, paramBoolean);
/* 56:   */   }
/* 57:   */   
/* 58:   */   public ExpandMacroToPathMap getExpandMacroMap()
/* 59:   */   {
/* 60:67 */     return this.a;
/* 61:   */   }
/* 62:   */   
/* 63:   */   public String substitute(String paramString, boolean paramBoolean)
/* 64:   */   {
/* 65:71 */     return this.a.substitute(paramString, paramBoolean);
/* 66:   */   }
/* 67:   */ }



/* Location:           E:\idea\

 * Qualified Name:     org.jetbrains.jps.model.serialization.JpsMacroExpander

 * JD-Core Version:    0.7.0.1

 */